import { ColumnGroupType, ColumnType } from "antd/es/table"
import { Link } from "react-router-dom"

import { ICardTablesBaseHandListResponse } from "@/api/business/types"
import { formatTime, getPublicCardsName, handleNumber, handleNumberColor } from "@/utils/util"

import TableContentLink from "../formItems/gameList/tableContentLink"

const hand = (
	newFormat: (arg: string) => string,
	_getFromDic: (arg: string, strictlyLabel?: boolean) => any
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	handNum: {
		key: "handNum",
		align: "center",
		dataIndex: "handNum",
		title: newFormat("dxn.card_ables_list.hand_brand"),
		width: 60
	},
	handCode: {
		key: "handCode",
		align: "center",
		dataIndex: "handCode",
		title: newFormat("dxn.game_list.hand_id"),
		width: 200,
		render: (handCode: string) => <Link to={`/dxn/gameManager/gameList/gameBase?handId=${handCode}`}>{handCode}</Link>
	},
	handId: {
		key: "handId",
		align: "center",
		dataIndex: "handId",
		title: newFormat("dxn.game_list.hand_id"),
		width: 200,
		render: (handId: string) => (
			<TableContentLink name={handId} to="/dxn/gameManager/gameList/gameBase" queryParams={{ handId: handId }} />
		)
	},
	handBeginTime: {
		key: "handBeginTime",
		align: "center",
		dataIndex: "handBeginTime",
		title: newFormat("dxn.card_ables_list.handle_start_time"),
		width: 130,
		render: (text: string) => formatTime(text)
	},
	handEndTime: {
		key: "handEndTime",
		align: "center",
		dataIndex: "handEndTime",
		title: newFormat("dxn.card_ables_list.handle_end_time"),
		width: 130,
		render: (text: string) => formatTime(text)
	},
	validPot: {
		key: "validPot",
		align: "center",
		dataIndex: "currency",
		title: newFormat("dxn.game_list.effective_bottom_pool"),
		width: 100,
		render: (currency: string, record: ICardTablesBaseHandListResponse) => handleNumber(currency, `${record.validPot}`)
	},
	publicCards: {
		key: "publicCards",
		align: "center",
		dataIndex: "publicCards",
		title: newFormat("dxn.game_list.public_brand_information"),
		width: 180,
		render: (publicCards: string) => getPublicCardsName(publicCards)
	},
	pumpingAmountHand: {
		key: "pumpingAmountHand",
		align: "center",
		dataIndex: "currency",
		title: newFormat("dxn.card_ables_list.play_cards_pump_water"),
		width: 180,
		render: (currency: string, record: ICardTablesBaseHandListResponse) => handleNumber(currency, `${record.pumpingAmount}`)
	},
	insuredNetAmountHand: {
		key: "insuredNetAmountHand",
		align: "center",
		dataIndex: "currency",
		title: newFormat("dxn.card_ables_list.insurance_profit_and_loss"),
		width: 100,
		render: (memberCurrency: string, record: ICardTablesBaseHandListResponse) => (
			<div style={{ color: handleNumberColor(record.insuredNetAmount) }}>
				{handleNumber(memberCurrency, record.insuredNetAmount.toString())}
			</div>
		)
	},
	hand_NetAmountHand: {
		key: "hand_NetAmountHand",
		align: "center",
		dataIndex: "currency",
		title: newFormat("dxn.card_ables_list.classic_insurance_profit_and_loss_hand"),
		width: 120,
		render: (memberCurrency: string, record: ICardTablesBaseHandListResponse) => (
			<div style={{ color: handleNumberColor(record.insuredNetAmount) }}>
				{handleNumber(memberCurrency, `${record.insuredNetAmount}`)}
			</div>
		)
	},
	hand_evInsuredNetAmount: {
		key: "hand_evInsuredNetAmount",
		align: "center",
		dataIndex: "evInsuredNetAmount",
		title: newFormat("dxn.card_ables_list.ev_insurance_profit_and_loss"),
		width: 120,
		render: (evInsuredNetAmount: string, record: any) => handleNumber(record.currency, `${evInsuredNetAmount}`)
	},
	handNetAmount: {
		key: "handNetAmount",
		align: "center",
		dataIndex: "currency",
		title: newFormat("dxn.card_ables_list.summary_of_member_wins_and_losses"),
		width: 100,
		render: (memberCurrency: string, record: ICardTablesBaseHandListResponse) => (
			<div style={{ color: handleNumberColor(record.handNetAmount) }}>
				{handleNumber(memberCurrency, record.handNetAmount.toString())}
			</div>
		)
	}
})
export default hand
